home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / lzw4c12.zip / SEE_ARC.C < prev    next >
Text File  |  1993-02-25  |  2KB  |  97 lines

  1. /*
  2. **   SEE_ARC.C       Copyright (C) 1992 by MarshallSoft Computing, Inc.
  3. **
  4. **   This program is used to list files compressed with MK_ARC. For
  5. **   example, to list all the files in 'C.ARF', type:
  6. **
  7. **      SEE_ARC C.ARF
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <dos.h>
  12. #include <fcntl.h>
  13. #include <sys\types.h>
  14. #include <sys\stat.h>
  15. #include <io.h>
  16.  
  17. #include "LZW4C.H"
  18. #include "RW_IO.H"
  19. #include "DIR_IO.H"
  20.  
  21. extern char *malloc();
  22. extern int free();
  23.  
  24. int SayError(int);
  25.  
  26. int main(argc,argv)
  27. int argc;
  28. char *argv[];
  29. {int i, k, c;
  30.  int RetCode;
  31.  char Filename[15];
  32.  int Files = 0;
  33.  int Dummy();
  34.  /* begin */
  35.  if(argc!=2)
  36.    {printf("Usage: SEE_ARC <archive_filespec>\n");
  37.     exit(1);
  38.    }
  39.  RetCode = InitLZW(malloc);
  40.  if(RetCode<0)
  41.    {SayError(RetCode);
  42.     exit(2);
  43.    }
  44.  puts("\nSEE_ARC 1.0: Type any key to abort...");
  45.  /* open input file for expansion */
  46.  if(!ReaderOpen(argv[1])) exit(4);
  47.  for(i=0;;i++)
  48.    {if(kbhit())
  49.       {puts("\n...Aborted by user !");
  50.        break;
  51.       }
  52.     /* get filename */
  53.     for(k=0;k<5;k++)
  54.        {c = Reader();
  55.         if(c==-1)
  56.            {ReaderClose();
  57.             TermLZW(free);
  58.             printf("\n%d files\n",Files);
  59.             exit(0);
  60.            }
  61.         /* skip past any 0's */
  62.         if(c!='\0') break;
  63.        }
  64.     Filename[0] = (char)c;
  65.     for(k=1;k<13;k++)
  66.        {c = Reader();
  67.         Filename[k] = (char)c;
  68.         if(c=='\0') break;
  69.        }
  70.     if(c!='\0')
  71.        {printf("ERROR: Cannot find filename in %s\n",argv[1]);
  72.         TermLZW(free);
  73.         exit(0);
  74.        }
  75.     if(strcmp(Filename,argv[1])==0)
  76.       {printf("ERROR: Archive contains file '%s' named same as archive\n",argv[1]);
  77.        exit(1);
  78.       }
  79.     else
  80.       {/* open output file */
  81.        Files++;
  82.        printf("%3d: %s \n",Files,Filename);
  83.        /* do the expansion */
  84.        if((RetCode=Expand(Reader,Dummy))<0)
  85.          {SayError(RetCode);
  86.           exit(5);
  87.          }
  88.       }
  89.    }
  90. }
  91.  
  92. int Dummy(TheByte)
  93. char TheByte;
  94. {
  95.  /* into the bit bucket ! */
  96.  return(0);
  97. }